package com.wysiwyg.common.exception;

import com.wysiwyg.common.web.response.ResponseEnum;
import lombok.Getter;

/**
 * 业务异常类
 * @author wwcc
 */
@Getter
public class BusinessException extends RuntimeException {
    
    private final ResponseEnum responseEnum;
    
    public BusinessException(String message) {
        super(message);
        this.responseEnum = ResponseEnum.BUSINESS_ERROR;
    }
    
    public BusinessException(ResponseEnum responseEnum) {
        super(responseEnum.getMsg());
        this.responseEnum = responseEnum;
    }
    
    public BusinessException(ResponseEnum responseEnum, String message) {
        super(message);
        this.responseEnum = responseEnum;
    }
    
    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.responseEnum = ResponseEnum.BUSINESS_ERROR;
    }
    
    public BusinessException(ResponseEnum responseEnum, Throwable cause) {
        super(responseEnum.getMsg(), cause);
        this.responseEnum = responseEnum;
    }
    
    public int getCode() {
        return responseEnum.getCode();
    }
    
    public String getMsg() {
        return responseEnum.getMsg();
    }
}